]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
viewSelector: Use state adjustment for apps page
authorGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>
Wed, 30 Dec 2020 20:45:09 +0000 (17:45 -0300)
committerMarge Bot <marge-bot@gnome.org>
Thu, 11 Feb 2021 15:50:31 +0000 (15:50 +0000)
Currently, ActivitiesContainer reacts to showAppsButton and
transitions between app grid and window picking states on
its own. In the future, we want full control over this.

ControlsManager already has a state adjustment that represents
all possible overview states. Propagate this adjustment up to
ActivitiesContainer, and use it to drive the transition.

This requires moving the callback to the showAppsButton to
ControlsManager, since now it control the state adjustment
itself, not ActivitiesContainer's adjustment.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1624>

js/ui/overviewControls.js
js/ui/viewSelector.js

index 4f0751d45f25b2e19e70bff1e7d5aaef6176cce7..9059d34e9bdf6610de39016a2be486c2d37115fd 100644 (file)
@@ -4,8 +4,11 @@
 const { Clutter, GObject, St } = imports.gi;
 
 const Dash = imports.ui.dash;
+const Overview = imports.ui.overview;
 const ViewSelector = imports.ui.viewSelector;
 
+var SIDE_CONTROLS_ANIMATION_TIME = Overview.ANIMATION_TIME;
+
 var ControlsState = {
     HIDDEN: 0,
     WINDOW_PICKER: 1,
@@ -123,7 +126,9 @@ class ControlsManager extends St.Widget {
                 this._updateAdjustment.bind(this));
 
         this.viewSelector = new ViewSelector.ViewSelector(this._searchEntry,
-            this._workspaceAdjustment, this.dash.showAppsButton);
+            this._workspaceAdjustment,
+            this.dash.showAppsButton,
+            this._stateAdjustment);
 
         this.add_child(searchEntryBin);
         this.add_child(this.dash);
@@ -132,9 +137,24 @@ class ControlsManager extends St.Widget {
         this.layout_manager = new ControlsManagerLayout(searchEntryBin,
             this.viewSelector, this.dash, this._stateAdjustment);
 
+        this.dash.showAppsButton.connect('notify::checked',
+            this._onShowAppsButtonToggled.bind(this));
+
         this.connect('destroy', this._onDestroy.bind(this));
     }
 
+    _onShowAppsButtonToggled() {
+        const checked = this.dash.showAppsButton.checked;
+
+        const value = checked
+            ? ControlsState.APP_GRID : ControlsState.WINDOW_PICKER;
+        this._stateAdjustment.remove_transition('value');
+        this._stateAdjustment.ease(value, {
+            duration: SIDE_CONTROLS_ANIMATION_TIME,
+            mode: Clutter.AnimationMode.EASE_OUT_QUAD,
+        });
+    }
+
     _onDestroy() {
         global.workspace_manager.disconnect(this._nWorkspacesNotifyId);
     }
index b1206188928e78a10c62da5ae0e3a925d576b89f..bf6f5bb69963c9c9003d931eacf4678755c9810c 100644 (file)
@@ -123,7 +123,7 @@ var ShowOverviewAction = GObject.registerClass({
 
 var ActivitiesContainer = GObject.registerClass(
 class ActivitiesContainer extends St.Widget {
-    _init(thumbnailsBox, workspacesDisplay, appDisplay, showAppsButton) {
+    _init(thumbnailsBox, workspacesDisplay, appDisplay, overviewAdjustment) {
         super._init();
 
         // 0 for window picker, 1 for app grid
@@ -138,9 +138,9 @@ class ActivitiesContainer extends St.Widget {
             this.queue_relayout();
         });
 
-        this._showAppsButton = showAppsButton;
-        showAppsButton.connect('notify::checked',
-            this._onShowAppsButtonToggled.bind(this));
+        overviewAdjustment.connect('notify::value', () => {
+            this._adjustment.value = Math.max(overviewAdjustment.value - 1, 0);
+        });
 
         this._thumbnailsBox = thumbnailsBox;
         this.add_child(thumbnailsBox);
@@ -158,16 +158,6 @@ class ActivitiesContainer extends St.Widget {
         this._update();
     }
 
-    _onShowAppsButtonToggled() {
-        const checked = this._showAppsButton.checked;
-
-        const value = checked ? 1 : 0;
-        this._adjustment.ease(value, {
-            duration: OverviewControls.SIDE_CONTROLS_ANIMATION_TIME,
-            mode: Clutter.AnimationMode.EASE_OUT_QUAD,
-        });
-    }
-
     _update() {
         const progress = this._adjustment.value;
 
@@ -243,7 +233,7 @@ var ViewSelector = GObject.registerClass({
         'page-empty': {},
     },
 }, class ViewSelector extends Shell.Stack {
-    _init(searchEntry, workspaceAdjustment, showAppsButton) {
+    _init(searchEntry, workspaceAdjustment, showAppsButton, overviewAdjustment) {
         super._init({
             name: 'viewSelector',
             x_expand: true,
@@ -298,7 +288,7 @@ var ViewSelector = GObject.registerClass({
             this._thumbnailsBox,
             this._workspacesDisplay,
             this.appDisplay,
-            showAppsButton);
+            overviewAdjustment);
         this._activitiesPage =
             this._addPage(activitiesContainer, _('Activities'), 'view-app-grid-symbolic');